import { Column, Entity, OneToMany } from 'typeorm';
import { BaseEntity } from './BaseEntity';
import { SysRoleUser } from './SysRoleUser';
import { SysRolePermission } from './SysRolePermission';
import { SysDepartmentRole } from './SysDepartmentRole';

@Entity()
export class SysRole extends BaseEntity {
  @Column({
    type: 'varchar',
    comment: '角色名称'
  })
  name: string;

  @Column({
    type: 'varchar',
    unique: true,
    comment: '角色代码'
  })
  code: string;

  @Column({
    default: false,
    type: 'boolean',
    comment: '是否禁用'
  })
  forbidden: boolean;

  @Column({
    type: 'varchar',
    nullable: true,
    comment: '角色详情描述'
  })
  remark: string;

  @OneToMany(() => SysRoleUser, s => s.SysRoleId)
  SysRoleUser: SysRoleUser[];

  @OneToMany(() => SysRolePermission, s => s.SysRoleId)
  SysRolePermission: SysRolePermission[];

  @OneToMany(() => SysDepartmentRole, s => s.SysRoleId)
  SysDepartmentRole: SysDepartmentRole[];
}
